home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Other Stuff / Demos ƒ / Demo AppMaker / Demo AppMaker™ / Demo AppMaker™.rsrc / TmpC_104_MainMenu < prev    next >
Encoding:
Text File  |  1990-03-23  |  2.7 KB  |  148 lines

  1. /* %filename% */
  2. /* Created %date% %time% by AppMaker */
  3.  
  4. %If lang = MPW%
  5. #include <Types.h>
  6. #include <Quickdraw.h>
  7. #include <Controls.h>
  8. #include <Dialogs.h>
  9. #include <Events.h>
  10. #include <Lists.h>
  11. #include <Menus.h>
  12. #include <TextEdit.h>
  13.  
  14. %end if%
  15. #include "Globals.h"
  16. #include "ResourceDefs.h"
  17. %for each menu gen include%
  18.  
  19. #include "%unitname%.h"
  20.  
  21. %If lang = MPW%
  22. #include <Desk.h>
  23. #include <ToolUtils.h>
  24.  
  25. %end if%
  26. #define nil            0L
  27. %If lang = MPW%
  28.  
  29. #pragma segment %unitname% 
  30. %end if%
  31.  
  32. /*----------*/
  33. void InitTitles ()
  34. {
  35.     %for each menu gen initTitles%
  36. } /*InitTitles*/
  37.  
  38. /*----------*/
  39. void LoadMenus ()
  40. {
  41.     %for each menu gen get%
  42.  
  43.     %for each menu gen insert%
  44.  
  45.     DrawMenuBar ();
  46. } /*LoadMenus*/
  47.  
  48. %for each menu gen doApple%
  49. /*----------*/
  50. void DoMenu (menuChoice)
  51. long            menuChoice;
  52. {
  53.     short            menuID;
  54.     short            itemNr;
  55.  
  56.     menuID = HiWord (menuChoice);
  57.     itemNr = LoWord (menuChoice);
  58.     
  59.     switch (menuID) {
  60.     case 0:
  61.             /*Do nothing*/;
  62.         break;
  63.     %for each menu gen dispatch%
  64.     } /*switch*/
  65.  
  66.     HiliteMenu (0);
  67. } /*DoMenu*/
  68.  
  69. /*----------*/
  70. MenuHandle        menu;
  71. Boolean            menuBarChanged;
  72.  
  73. /*----------*/
  74. void Enable (short        itemNr,
  75.              Boolean    enabled);
  76.  
  77. void Enable (itemNr, enabled)
  78. short        itemNr;
  79. Boolean        enabled;
  80. {
  81.     if (enabled) {
  82.         EnableItem  (menu, itemNr);
  83.     } else {
  84.         DisableItem (menu, itemNr);
  85.     }
  86. } /*Enable*/
  87.  
  88. /*----------*/
  89. void EnableTitle (MenuHandle    menu,
  90.                   Boolean        enabled);
  91. void EnableTitle (menu, enabled)
  92. MenuHandle        menu;
  93. Boolean            enabled;
  94. {
  95.     if (enabled != ((**menu).enableFlags & 1)) {
  96.         menuBarChanged = true;
  97.     }
  98.     if (enabled) {
  99.         EnableItem  (menu, 0);
  100.     } else {
  101.         DisableItem (menu, 0);
  102.     }
  103. } /*EnableTitle*/
  104.  
  105. /*----------*/
  106. void UpdateMenus ()
  107. {
  108.     WindowPeek        frontPeek;
  109.     Boolean            isFront;    /*is there a front window?*/
  110.     Boolean            isCur;        /*is there a current window?*/
  111.     Boolean            isDirty;    /*is it dirty?*/
  112.     Boolean            hasFile;    /*does it have a file?*/
  113.     Boolean            isSelected;    /*is anything selected?*/
  114.     Boolean            isDesk;        /*is the front window a desk acc?*/
  115.     Boolean            isText;        /*is there a current text field?*/
  116.     Boolean            isScrap;    /*is there any scrap?*/
  117.  
  118.     menuBarChanged = false;
  119.  
  120.     isFront        = (FrontWindow () != nil);
  121.     isCur        = (curWindow != nil);
  122.     isDirty     = false;
  123.     hasFile     = false;
  124.     isSelected    = false;
  125.     if (isCur) {
  126.         isDirty        =  cur->dirty;
  127.         hasFile        = (cur->fileNum != 0);
  128.     }
  129.  
  130.     isDesk = false;
  131.     if (isFront) {
  132.         frontPeek    = (WindowPeek) FrontWindow ();
  133.         isDesk        = (frontPeek->windowKind < 0);
  134.     }
  135.     isText        = isCur && (cur->text != nil);
  136.     isScrap        = false;
  137.     if (isText) {
  138.         isSelected    = ((**(cur->text)).selStart != (**(cur->text)).selEnd);
  139.         isScrap        = (TEGetScrapLen () > 0);
  140.     }
  141.  
  142.     %for each menu gen enable%    
  143.     if (menuBarChanged) {
  144.         DrawMenuBar ();
  145.     }
  146. } /*UpdateMenus*/
  147.  
  148. /* %unitname% */